
import * as echarts from '../../../../ec-canvas/echarts';
import { countS } from '../../../../utils/util.js'
const systemInfo = wx.getSystemInfoSync();


Component({
  properties: {
  },

  data: {
    ec: {
      lazyLoad: true
    },
  },
  ready() {
  },
  pageLifetimes: {

  },
  methods: {

    countEcharts(data) {
      let mychart = this.selectComponent("#mychart-dom-bar");
      mychart.init((canvas, width, height) => {
        const Chart = echarts.init(canvas, null, {
          width: width,
          height: height
        });
        console.log(data)
        Chart.setOption(this.getCategoryOption(data))
      })
    },

    // 配置柱状图
    getCategoryOption(data) {
      return {
        tooltip: {
          trigger: 'axis',
          axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        legend: {
          data: ['产量变化', '产量数据'],
          color: ['#ffd285', '#4a63c7'],
          itemWidth: 10.5,
          itemHeight: 7.5,
          textStyle: {
            color: ['#ffd285', '#4a63c7'],
            fontSize: 9,
          }
        },
        grid: {
          top: 24,
          left: 50,
          right: 30,
          bottom: 26,
          height: systemInfo.windowWidth <=360 && 85 || 110
        },
        xAxis: {
          name: '时间',
          animation: false,
          nameGap: 5.5,
          type: 'category',
          data: data.result.labels,
          splitLine: {
            show: false
          },

          nameTextStyle: {
            color: "#BAD7FF",
            fontSize: 12,

          },
          axisLabel: {
            margin: 10,
            color: "#BAD7FF",
            fontSize: 9,
            // interval: 1
          },
          axisLine: {
            lineStyle: {
              color: '#39529A'
            }
          },


        },
        yAxis: {
          type: 'value',
          name: '产量',
          nameGap: 5.5,
          min: 0,
          // max: 8,
          splitLine: {
            show: false
          },

          nameTextStyle: {
            color: "#BAD7FF",
            fontSize: 12,

          },
          axisLabel: {
            margin: 10,
            color: "#BAD7FF",
            fontSize: 9
          },
          axisLine: {
            lineStyle: {
              color: '#39529A'
            }
          },
        },
        series: [
          {
            name: "产量变化",
            type: 'line',
            symbol: 'circle',
            symbolSize: 5,
            label: {
              normal: {
                position: 'insideRight'
              }
            },
            itemStyle: {
              color: '#ffd285'
            },
            data: data.result.prod
          },
          {
            name: "产量数据",
            type: 'bar',
            // barWidth: stack && '7.5' || '',
            label: {
              normal: {
                position: 'insideRight'
              }
            },
            itemStyle: {
              color: '#4a63c7'
            },
            data: data.result.prod
          }
        ]
      }
    }
  }
})